<template>
  <div class="app-container">
    <h1>App 根组件</h1>
    <hr />
    <div class="box">
      <!-- 渲染left和right的 -->
      <left class="little-box" :msg="message" :user="userinfo"></left>
      <right class="little-box" @numberChange="getNewNumber"></right>
    </div>
    <hr />
    <div>
      <p>right传递过来的值：{{ countFromRight }}</p>
    </div>
  </div>
</template>

<script>
import Left from "@/components/Left.vue";
import Right from "@/components/Right.vue";
export default {
  // 私有组件
  components: {
    left: Left,
    right: Right,
  },

  data() {
    return {
      message: "hello 123",
      userinfo: {
        name: "小明",
        age: 18,
      },
      countFromRight: 0,
    };
  },
  methods: {
    getNewNumber(value) {
      this.countFromRight = value;
    },
  },
};
</script>

<style lang="less">
.app-container {
  padding: 1px 20px 20px;
  background-color: #efefef;
}

.little-box {
  float: left;
  border: 5px solid black;
  padding: 100px;
}
</style>
